//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// (C) Copyright 2006 Marvell International Ltd.
// All Rights Reserved
//

#ifndef __QCI_PRIVATE_H__
#define __QCI_PRIVATE_H__

#include "xllp_defs.h"
#include "xllp_ost.h"
#include "xllp_mfp_plat.h"
#include "xllp_gpio_plat.h"
#include "xllp_mfp.h"
#include "xllp_camera.h"
#include "xllp_ci.h"
#include "xllp_i2c.h"
#include "xllp_clkmgr.h"
#include "xllp_intc.h"
#include "qci.h"


#ifdef DEBUG

#define DEBUGMASK(bit)       (1 << (bit))

#define MASK_ERROR           DEBUGMASK(0)
#define MASK_WARN            DEBUGMASK(1)
#define MASK_INIT            DEBUGMASK(2)
#define MASK_FUNCTION        DEBUGMASK(3)
#define MASK_IOCTL           DEBUGMASK(4)
#define MASK_DEVICE          DEBUGMASK(5)

#define ZONE_ERROR           DEBUGZONE(0)
#define ZONE_WARN            DEBUGZONE(1)
#define ZONE_INIT            DEBUGZONE(2)
#define ZONE_FUNCTION        DEBUGZONE(3)
#define ZONE_IOCTL           DEBUGZONE(4)
#define ZONE_DEVICE          DEBUGZONE(5)
#define ZONE_ENUM            DEBUGZONE(6)

#endif

#ifdef __cplusplus
extern "C"{
#endif 

extern XLLP_GPIO_T *gpio_reg;
extern P_XLLP_VUINT32_T mfp_reg;
extern unsigned int clk_reg;
extern unsigned int ost_reg;
extern unsigned int ci_reg;
extern XLLP_I2C_T *i2c_reg;
extern XLLP_INTC_T *intc_reg;
extern HANDLE qci_intr_event;
extern DWORD qci_sys_intr;
extern int still_skips;

#define HISTOGRAM_LUT_BUF_SIZE	1024

typedef struct
{
	char histogram_lut_buf[HISTOGRAM_LUT_BUF_SIZE];
	XLLP_CI_DMAC_DESCRIPTOR_T histogram_lut_descriptor;
} histogram_lut_buf_t;

//extern frame_t *dma_frame_head;
//extern frame_t *dma_frame_tail;

void qci_clock_enable(BOOL is_on);
void qci_enable();
void capture_start(int in_still_skips);
void capture_stop();
BOOL prepare_format(format_t* format);
void qci_set_frame_format(format_t *format);
void qci_set_interface(qci_interface_t* intf);
void qci_set_master_timing(qci_master_timing_t* timing);
void qci_set_image_format(int in_format, 
                          int out_format);
BOOL add_callback(callback_data_t* callback_data);
void callback(frame_t* frame);
BOOL set_current_frame_list(format_t* format);
void dma_load();
void dma_save();
// frame_t *dma_frame_take();
// void dma_frame_submit(frame_t *frame);
BOOL init_all();
void power_on();

void dma_buf_alloc(dma_buf_t *buf, unsigned int size, BOOL cache);
void dma_buf_free(dma_buf_t *buf);

void qci_image_proc_cfg(qci_image_proc_cfg_t* cfg);


#ifdef __cplusplus
}
#endif 

#endif